<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>anz2blend - Basic Usage</title>
		<style type="text/css" media="screen">
			body { padding: 5px 20px; }
			img { border: none; }
			h3 { padding-top: 10px; border-top: 3px solid #bab2c0; }
			h4 { padding-top: 5px; border-top: 2px solid #bab2c0; }
			a, a:active, a:visited { color: black; text-decoration: none; }
			a:hover { text-decoration: underline; color: #bab2c0; }
		</style>
	</head>
	<body>
	<h1>Basic Usage</h1>
	<h3>Contents</h3>
	<ul>
		<li><a href="#a0">Package</a></li>
		<li><a href="#a1">Installation</a></li>
		<li><a href="#a2">Things to note</a></li>
		<li><a href="#a3">Making a simple bracelet model</a></li>
		<li><a href="#a4">How to</a>
			<ul>
				<li><a href="#a41">Two-sided faces</a></li>
				<li><a href="#a42">Automatic bone assignment</a></li>
				<li><a href="#a43">Animated textures</a></li>
				<li><a href="#a44">Physics / Hair</a></li>
				<li><a href="#a45">Camera animation</a></li>
				<li><a href="#a46">Texture scaling</a></li>
				<li><a href="#a47">Bone animation</a></li>
			</ul>
		</li>
		<li><a href="#a5">About</a></li>
	</ul>
	<h3 id="a0">Package</h3>
	<em>anz_import.py</em> &mdash; importer script<br />
	<em>anz_export.py</em> &mdash; exporter script<br />
	<em>anz_autobone.py</em> &mdash; "Mesh" category script to assign bones automatically from another object<br />
	<em>anz_autoipo.py</em> &mdash; "Animation" category material animation helper script<br />
	<em>cm3d_camera_import.py</em> &mdash; camera animation importer<br />
	<em>cm3d_camera_export.py</em> &mdash; camera animation exporter<br />
	<em>NvTriStripper-cli.exe</em> &mdash; command line version of the nVidia's NvTriStrip tool.
	<h3 id="a1">Installation</h3>
	<p>
	Put the <em>.py</em> files and <em>NvTriStripper-cli.exe</em> inside Blender's scripts folder (usually <em>%AppData%\Blender Foundation\Blender\.blender\scripts</em>)</p>
	<p>
	
	<h3 id="a2">Things to note</h3>
	<ol>
		<li>You need to manually triangulate your meshes before exporting them. The script won't do it for you.</li>
		<li>The same goes for the modifiers, which you will have to apply manually.</li>
		<li>Using PNG textures works, but can produce some culling artifacts depending on the model's slot in game. To be sure, use DDS, DXT1, non alpha textures.</li>
		<li>Everything is very experimental and can break randomly</li>
	</ol>
	
	<h3 id="a3">Making a simple bracelet model</h3>
	<p>
		This basic demonstration assumes that you are familiar with Blender.
	</p>
	<h4>Step 1 - Import a reference</h4>
	<p>
		Here I am using <em>Arm000_000.anz</em>.
	</p>
	<a href="images/step1.png"><img alt="" src="images/thumbs/step1.png" /></a>

	<h4>Step 2 - Create the bracelet mesh</h4>
	<p>
		<em>Space &raquo; Add &raquo; Mesh &raquo; Torus</em>, default parameters.<br />
		If you want, you can check the Arm's vertices weight to help yourself positioning the bracelet:<br />
		<em>Ctrl + Tab</em> to enter Weight Paint mode and select the appropriate Vertex Group from the Link and Materials tab.
	</p>
	<a href="images/step2.png"><img alt="" src="images/thumbs/step2.png" /></a>
	
	<h4>Step 3 - Attach the bracelet to a bone</h4>
	<p>
		You will need to create a vertex group with the same name as the bone you want to attach the bracelet to.<br />
		Create a new vertex group called <em>Bip01_L_Forearm</em> and assign all vertices to it.
	</p>
	<a href="images/step3.png"><img alt="" src="images/thumbs/step3.png" /></a>
	
	<h4>Step 4 - Material, Texture and UVs</h4>
	<p>
		Add a material to the bracelet:<br />
		<em>Shading panel</em> / <em>Material buttons</em> &raquo; <em>Add New</em>
	</p>
	<img alt="" src="images/step4-mat.png" />
	<p>
		In the UV Editor, create a new image and unwrap the bracelet.
	</p>
	<a href="images/step4.png"><img alt="" src="images/thumbs/step4.png" /></a>
	<p>
		Add <em>Ambient Occlusion</em>.
	</p>
	<img alt="" src="images/step5-ao.png" />
	<p>
		<em>Bake Ambient Occlusion</em> on the image you have just created.
	</p>
	<img alt="" src="images/step5-bake.png" />
	<p>
		Now attach the generated texture to the bracelet's material.
	</p>
	<img alt="" src="images/step5-tex.png" />
	<p>
		You will end up with something like this.
	</p>
	<a href="images/step5.png"><img alt="" src="images/thumbs/step5.png" /></a>
	<p>
		Save the texture in the UV Editor as a PNG image.<br />
		You can edit it if you want. Here I changed the colour to pink and reduced the shadows a bit.<br />
		I have also converted the image to DDS (DXT1, no alpha) using nVidia's dds plugin for Photoshop.
	</p>	
	
	<h4>Step 5 - Exporting</h4>
	<p>
		You will need to triangulate the bracelet's mesh before exporting it.<br />
		Duplicate the bracelet's object (<em>Shift + D</em> &raquo; <em>Escape</em>).
		Switch to Edit Mode, select everything and press <em>Ctrl + T</em>.
		Here's what you should normally have.
	</p>
	<a href="images/step6.png"><img alt="" src="images/thumbs/step6.png" /></a>
	<p>
		Since we only want to export the bracelet, we restrict the renderability of other objects.<br />
		Launch the exporter script, chose the destination and the <em>Reference ANZ file</em>. Here I used <em>Wrist000_000.anz</em> as reference.<br />This is only used to copy the armature data (not the attached bones, these are controlled in Blender using vertex groups) and animations.
	</p>
	
	<h4>Result</h4>
	<img alt="" src="images/stepend.jpg" />
	
	<h3 id="a4">How to</h3>
	<h4 id="a41">Two-sided faces</h4>
	<ul>
		<li>Method 1: using Blender</li>
	</ul>
	<p>
		The exporter can automatically create proper double-sided surfaces.<br />
		You will need to set the face's display mode to <em>Twoside</em>:
	</p>
	<a href="images/two_sided_faces.png"><img alt="" src="images/thumbs/two_sided_faces.png" /></a>
	<p>
		The <em>Texture Face</em> panel is only displayed when the mesh has a UV layer.<br />
		Select the face you want to make double-sided (that face becomes the Active Face) and click on <em>Twoside</em>.<br />You can then select additional faces and then clicking on Copy in the top right corner to copy the Active Face mode to other selected faces.
	</p>
	
	<ul>
		<li>Method 2: native double sided faces</li>
	</ul>
	
	<p>
		To use the in-game native two-sided faces support, prefix the mesh's material name with <strong>d-</strong><br />
		example: <code>my_material</code> &raquo; <code>d-my_material</code>.<br />
		This will affect the whole mesh.
	</p>
	
	<h4 id="a42">Automatic bone assignment</h4>
	<p>
		You can find the auto bones script in the <em>Mesh</em> category.<br />
		It will automatically create vertex groups for the <em>destination</em> object using data from a different <em>source</em> object.<br />
		The <em>active object</em> is the destination and the other <em>selected object</em> is the source.
	</p>
	<img alt="" src="images/autobone0.png" />
	<p>
		Here the script will use the <em>source</em> object to create vertex groups for the <em>dest</em> object.
	</p>
	<img alt="" src="images/autobone1.png" />
	
	<h4 id="a43">Animated textures</h4>
	<p>
		See sample files in <a href="samples/material_animation"><code>/doc/samples/material_animation</code></a>
	</p>
	<p>
		Use the <em>Material IPO</em> to control the texture offset:
	</p>
	<a href="images/texanim.png"><img alt="" src="images/thumbs/texanim.png" /></a>
	<p>
		In game, the animations run at about 30 frames per second.<br />
		To move from column to column, <strong>increase</strong> <em>ofsX</em> by <code>1 / (number of columns)</code><br />
		To move from a row to another, <strong>decrease</strong> <em>ofsY</em> by <code>1 / (number of rows)</code><br />
		To insert an <em>ofs</em> keyframe, place the cursor in the area marked in yellow and press <em>I</em> (capital "i") and select <em>ofs</em>.
	</p>
	<p>
		You can also use the <em>anz_autoipo.py</em> script from the <em>Animation</em> category to automatically generate IPO curves.
	</p>

	<h4 id="a44">Physics / Hair</h4>
	<p>
		See sample files in <a href="samples/physics"><code>/doc/samples/physics</code></a>
	</p>
	
	Things to note:<br />
	<ul>
		<li>You should import a body armature and delete non relevant bones:<br />
			<img alt="" src="images/phy-struct.png" /><br />
			<em>cm3d_ntop</em> is the root bone<br />
			<em>Bip01_Spine</em> is the attach bone. For hair model, this will be Bip01_Head, etc...<br />
		</li>
		<li>See hair model anz files for bone names reference</li>
		<li>To enable physics for your model, set your csv as follows:<br />
			<img alt="" src="images/physics-csv.png" /><br />
			<em>Attach Bone</em> should normally be a direct child of the root bone to which you attach your physics bones.<br />
			<em>Phys Soft</em> is some sort of damping value, -200 is what seems to be used for hair models, just don't set it to 0.<br />
			<em>Model Type</em> enables physics calculation for the armature.<br />
		</li>
	</ul>

	<h4 id="a45">Camera animation</h4>
	<p>
		See sample .blend file in <a href="samples/camera_animation"><code>/doc/samples/camera_animation</code></a><br />
		You may also want import the dance stage map as a reference <em>(Haikei_000_000.anz)</em>
	</p>
	
	Things to note:<br />
	<ul>
		<li>You need a Camera object called <em>CM3DCamera</em></li>
		<li>You also need a second object which will act as a target for the camera</li>
		<li>The Camera must have a <em>Track To</em> constraint with your Tracker object as target</li>
		<li>You have to set the animation length in the Scene/Anim panel</li>
		<li>Set the Camera Lens to 70 degrees to have the same fov as in-game</li>
	</ul>
	
	<p>
		<img alt="" src="images/camera_const_outline.png" /><br />
		<small>CM3DCamera object tracking an empty object called CM3DTracker.</small>
	</p>
	
	<p>
		<img alt="" src="images/camera_end_frame.png" /><br />
		<small>Animation length. The dance camera animation length is 3422 frames.</small>
	</p>
	
	<p>
		<img alt="" src="images/camera_lens_fov.png" /><br />
		<small>Camera's field of view, in degrees.</small>
	</p>
	
	<h4 id="a46">Texture scaling</h4>
	<p>
		It is possible to export the scale of the texture space:
	</p>
	<img alt="" src="images/uvscale01.png" />
	<p>Example:</p>
	<img alt="" src="images/uvscale_11.png" /><br />
	<img alt="" src="images/uvscale_1010.png" /><br />
	<img alt="" src="images/uvscale_101.png" />
	
	<h4 id="a47">Bone animations</h4>
	<p>
		Sample files: <a href="samples/bone_animation"><code>/doc/samples/bone_animation</code></a>
	</p>
	
	<p><em>Note that the imported animations are very inaccurate and are only to be used as reference (slot IDs, positioning, alignment, etc.)</em></p>
	
	<p><strong>Quick How-to</strong></p>
		
	<p>
		Let's replace this pose from the Visual Pack:<br />
		<img alt="" src="images/poseicon.png" />
	</p>
	
	<p>
		First, we need to know the <em>id</em> of the animation we want to replace.<br />
		Import <em>\Motion_VP\mot_heroin_pose.anz</em> into Blender:<br />
		<img alt="" src="images/pose_step01.png" />
	</p>
	
	<p>
		You can access the animations using the action view:<br />
		<a href="images/pose_step02.png"><img alt="" src="images/thumbs/pose_step02.png" /></a>
	</p>
	
	<p>
		Animations in slots 14 and 15 are the ones we want to replace.<br />
		Normally, the first one is the starting animation (where the character actually takes the pose).<br />
		The second one is the looped, idle animation.<br />
	</p>
	
	<p>
		Now, create a new, empty project and import the previous file, this time without the animations:<br />
		<img alt="" src="images/pose_step03.png" />
	</p>
	
	<p>
		You will get something like this:<br />
		<a href="images/pose_step04.png"><img alt="" src="images/thumbs/pose_step04.png" /></a>
	</p>

	<p>
		Make the poses:<br />
		<a href="images/pose_step05.png"><img alt="" src="images/thumbs/pose_step05.png" /></a><br />
		<strong>Action names must follow this format: </strong><code>ARMATURE_OBJECT_NAME.SLOT_ID</code><br />
		Here the armature object bame is <em>BodyArmature</em>, therefore the actions are called <em>BodyArmature.14</em> and <em>BodyArmature.15</em><br />
		You can import additional parts, like the arms of the head, to help you in making the pose, just make sure to disable the <em>renderability</em>.
	</p>
	
	<p>
		Export and repack:<br />
		<img alt="" src="images/pose_step06.png" /><br />
		Use the original file as reference to keep the animations you don't want to replace.
	</p>
	
	<p>
		Result:<br />
		<a href="images/pose_final.jpg"><img alt="" src="images/thumbs/pose_final.jpg" /></a>
	</p>

	<h3 id="a5">About</h3>
	<ul>
		<li><strong>Version: </strong>0.4.0</li>
		<li><strong>Source: </strong><a href="http://code.google.com/p/anz2blend/">http://code.google.com/p/anz2blend/</a></li>
		<li><strong>Contact: </strong><a href="mailto:desuwane@gmail.com">desuwane@gmail.com</a></li>
	</ul>
	</body>
</html>